<script>
    //生成器就是一个特殊的函数，可以将一个函数分成多步执行
    function* gen(){
        console.log("aaa");
        yield "111";

        console.log("bbb");
        yield "222";
        
        console.log("ccc");
        yield "333";
    }

    let iterator=gen();
    console.log(iterator);
    console.log(iterator.next());  //{value: '111', done: false}
    console.log(iterator.next());  //{value: '222', done: false}
    console.log(iterator.next());  //{value: '333', done: false}
    console.log(iterator.next());  //{value: undefined, done: true}

    for(let i of gen()){
        console.log(i);
    }
</script>